<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">

<title>class OracleController - Rails Application Documentation</title>

<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
</script>

<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>


<body id="top" class="class">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="./index.html">Home</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>app/controllers/oracle_controller.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    <nav id="parent-class-section" class="section">
  <h3 class="section-header">Parent</h3>
  
  <p class="link"><a href="ApplicationController.html">ApplicationController</a>
  
</nav>

    
    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-i-findDoublets">#findDoublets</a>
    
    <li><a href="#method-i-test">#test</a>
    
    <li><a href="#method-i-to_generator">#to_generator</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="./doc/README_FOR_APP.html">README_FOR_APP</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="./MarcTools.html">MarcTools</a>
  
    <li><a href="./MarcTools/MarcConverter.html">MarcTools::MarcConverter</a>
  
    <li><a href="./ApplicationController.html">ApplicationController</a>
  
    <li><a href="./ApplicationHelper.html">ApplicationHelper</a>
  
    <li><a href="./CzController.html">CzController</a>
  
    <li><a href="./MarcconverterController.html">MarcconverterController</a>
  
    <li><a href="./Object.html">Object</a>
  
    <li><a href="./OracleController.html">OracleController</a>
  
    <li><a href="./PersonController.html">PersonController</a>
  
    <li><a href="./PersonHelper.html">PersonHelper</a>
  
    <li><a href="./RsqvHelper.html">RsqvHelper</a>
  
    <li><a href="./RsqvpreviewController.html">RsqvpreviewController</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="class">class OracleController</h1>

  <div id="description" class="description">
    
  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    <!-- Methods -->
    
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Instance Methods</h3>

    
      <div id="method-i-findDoublets" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">findDoublets</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="findDoublets-source">
            <pre><span class="ruby-comment"># File app/controllers/oracle_controller.rb, line 19</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">findDoublets</span>()
  <span class="ruby-comment">#create table ss_dubl and indexes</span>
  <span class="ruby-comment">#create table ss_dubl as select h.rismnr, k.bvsigl,lower(regexp_replace(h.hsexsg, \'\s*\',\'\')), h.kutit from hspr01 h</span>
  <span class="ruby-comment">#inner join hss101 hs on (hs.pr_isn=h.h0001)</span>
  <span class="ruby-comment">#inner join ksprpd k on (hs.ksu200=k.k0001)</span>
  <span class="ruby-comment"># where h.rismnr is not NULL</span>

  <span class="ruby-identifier">conn</span>=<span class="ruby-constant">OCI8</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'rism1'</span>,<span class="ruby-string">'rism1'</span>,<span class="ruby-string">'//rism-online.info:1521/orcl'</span>)
  <span class="ruby-identifier">dn</span> =<span class="ruby-string">'dn:http://www.loc.gov/MARC21/slim'</span>
  <span class="ruby-ivar">@result</span>=[]
  <span class="ruby-ivar">@fin</span>=[]
  <span class="ruby-identifier">xml_document</span> = <span class="ruby-constant">LibXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">file</span>(<span class="ruby-string">'/home/stephan/RSQV/test.xml'</span>)
  <span class="ruby-identifier">book_xpath</span> = <span class="ruby-string">'//dn:record'</span>    
  <span class="ruby-identifier">xml_document</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">book_xpath</span>,<span class="ruby-identifier">dn</span>).<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span>
    <span class="ruby-ivar">@result</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">n</span>.<span class="ruby-identifier">find</span>(<span class="ruby-string">'dn:controlfield[@tag=&quot;001&quot;]'</span>,<span class="ruby-identifier">dn</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">content</span>,
      [<span class="ruby-identifier">n</span>.<span class="ruby-identifier">find_first</span>(<span class="ruby-string">'dn:datafield[@tag=&quot;852&quot;]/dn:subfield[@code=&quot;a&quot;]'</span>, <span class="ruby-identifier">dn</span>).<span class="ruby-identifier">content</span>,
      <span class="ruby-identifier">n</span>.<span class="ruby-identifier">find_first</span>(<span class="ruby-string">'dn:datafield[@tag=&quot;852&quot;]/dn:subfield[@code=&quot;c&quot;]'</span>, <span class="ruby-identifier">dn</span>).<span class="ruby-identifier">content</span>,
      <span class="ruby-identifier">n</span>.<span class="ruby-identifier">find_first</span>(<span class="ruby-string">'dn:datafield[@tag=&quot;100&quot;]/dn:subfield[@code=&quot;a&quot;]'</span>, <span class="ruby-identifier">dn</span>).<span class="ruby-identifier">content</span>,
      ]]
  }

  <span class="ruby-ivar">@result</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">shelfmark</span>=<span class="ruby-identifier">n</span>[<span class="ruby-value">1</span>][<span class="ruby-value">1</span>].<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">gsub</span> <span class="ruby-regexp">/\s/</span>, <span class="ruby-string">''</span>
    <span class="ruby-identifier">sigl</span>=<span class="ruby-identifier">n</span>[<span class="ruby-value">1</span>][<span class="ruby-value">0</span>]
    <span class="ruby-identifier">sql</span>=<span class="ruby-string">'select rismnr, bvsigl,hsexsg, kutit from ss_dubl where hsexsg=\'</span><span class="ruby-operator">+</span><span class="ruby-identifier">shelfmark</span><span class="ruby-operator">+</span><span class="ruby-string">'\ and bvsigl=\'</span><span class="ruby-operator">+</span><span class="ruby-identifier">sigl</span><span class="ruby-operator">+</span><span class="ruby-string">'\'</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">shelfmark!</span>=<span class="ruby-string">'[ohne Signatur]'</span>
      <span class="ruby-identifier">c</span>=<span class="ruby-identifier">conn</span>.<span class="ruby-identifier">exec</span>(<span class="ruby-identifier">sql</span>)
      <span class="ruby-ivar">@fin</span> <span class="ruby-operator">&lt;&lt;</span> [[<span class="ruby-identifier">n</span>[<span class="ruby-value">0</span>][<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">20</span>]<span class="ruby-operator">+</span><span class="ruby-string">': '</span>, <span class="ruby-identifier">sigl</span>, <span class="ruby-identifier">shelfmark</span>, <span class="ruby-string">'('</span><span class="ruby-operator">+</span><span class="ruby-identifier">n</span>[<span class="ruby-value">1</span>][<span class="ruby-value">2</span>]<span class="ruby-operator">+</span><span class="ruby-string">')'</span>], <span class="ruby-identifier">c</span>.<span class="ruby-identifier">fetch</span>]
      <span class="ruby-identifier">c</span>.<span class="ruby-identifier">close</span>
    <span class="ruby-keyword">end</span>
  }

<span class="ruby-keyword">end</span></pre>
          </div><!-- findDoublets-source -->
          
        </div>

        

        
      </div><!-- findDoublets-method -->

    
      <div id="method-i-test" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">test</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="test-source">
            <pre><span class="ruby-comment"># File app/controllers/oracle_controller.rb, line 13</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test</span>
  <span class="ruby-identifier">conn</span>=<span class="ruby-constant">OCI8</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'rism1'</span>,<span class="ruby-string">'rism1'</span>,<span class="ruby-string">'//rism-online.info:1521/orcl'</span>)
  <span class="ruby-identifier">sql</span>=<span class="ruby-string">'select kutit from hspr01 where rismnr is not NULL and rownum &lt; 100'</span>
  <span class="ruby-ivar">@result</span>=<span class="ruby-identifier">to_generator</span>(<span class="ruby-identifier">conn</span>.<span class="ruby-identifier">exec</span>(<span class="ruby-identifier">sql</span>))
<span class="ruby-keyword">end</span></pre>
          </div><!-- test-source -->
          
        </div>

        

        
      </div><!-- test-method -->

    
      <div id="method-i-to_generator" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">to_generator</span><span
            class="method-args">(cursor)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="to_generator-source">
            <pre><span class="ruby-comment"># File app/controllers/oracle_controller.rb, line 5</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_generator</span>(<span class="ruby-identifier">cursor</span>)
  <span class="ruby-constant">Enumerator</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">enum</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">while</span> <span class="ruby-identifier">r</span>=<span class="ruby-identifier">cursor</span>.<span class="ruby-identifier">fetch</span>
      <span class="ruby-identifier">enum</span>.<span class="ruby-identifier">yield</span> <span class="ruby-identifier">r</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- to_generator-source -->
          
        </div>

        

        
      </div><!-- to_generator-method -->

    
    </section><!-- public-instance-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.2.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

